function showIndexBgfktj(){
    var chart_index_bgfktj = echarts.init(document.getElementById('chart_index_bgfktj'),'macarons');

    options_bgfktj = {
        title : {
            text: '按问题类别统计',
            x:'center',
        },
        tooltip : {
            trigger: 'item',
            formatter: "{a} <br/>{b} : {c} ({d}%)"
        },
        textStyle: {
            fontSize: 13
        },
        series : [
            {
                name: '工单数量',
                type: 'pie',
                radius : '50%',
                center: ['50%', '50%'],
                // roseType: "area",
                data:[
                    {value:335, name:'党的政治建设'},
                    {value:310, name:'党的思想建设'},
                    {value:234, name:'党的组织建设'},
                    {value:135, name:'党的作风建设'},
                    {value:1548, name:'党的纪律建设'},
                    {value:457, name:'围绕夺取反腐败斗争压倒性胜利'},
                    {value:348, name:'加强对巡视巡察整改情况的监督检查'},
                    {value:627, name:'其他'},
                ],
                itemStyle: {
                    emphasis: {
                        shadowBlur: 10,
                        shadowOffsetX: 0,
                        shadowColor: 'rgba(0, 0, 0, 0.5)'
                    },
                    normal: {
                        label: {
                            show: true,
                            formatter:function(val){   //让series 中的文字进行换行
                                return val.name.split("-").join("\n");

                            }
                        }
                    }
                },
            }
        ]
    };
    chart_index_bgfktj.setOption(options_bgfktj);

}

function showIndexZrbm(){
    var chart_index_zrbm = echarts.init(document.getElementById('chart_index_zrbm'),'macarons');

    options_zrbm = {
        title : {
            text: '按责任领域统计',
            x:'center'
        },
        tooltip : {
            trigger: 'axis',
            // formatter: "{a} <br/>{b} : {c} ({d}%)"
        },
        // legend: {
        // 	orient: 'vertical',
        // 	left: 'left',
        // 	data: ['领域1','领域2','领域3','领域4','领域5','领域6','领域7','领域8']
        // },
        toolbox: {
            show : true,
            feature : {
                mark : {show: true},
                dataView : {show: true, readOnly: false},
                magicType : {show: true, type: ['line', 'bar', 'stack', 'tiled']},
                restore : {show: true},
                saveAsImage : {show: true}
            }
        },
        calculable : true,
        xAxis : [
            {
                type : 'category',
                boundaryGap : true,
                data : []
            }
        ],
        yAxis : [
            {
                type : 'value'
            }
        ],
        grid: {
            left: '3%',
            right: '4%',
            containLabel: true
        },
        dataZoom: [{
            type: 'inside',
            start: 0,
            end: 100,
        }, {
            start: 74,
            end: 100,
            handleSize: '80%',
            handleStyle: {
                color: '#fff',
                shadowBlur: 3,
                shadowColor: 'rgba(0, 0, 0, 0.6)',
                shadowOffsetX: 2,
                shadowOffsetY: 2
            }
        }],
        series : [
            {
                name: '工单数量',
                type: 'bar',
                // radius : ['35%', '110%'],
                // center: ['50%', '60%'],
                // roseType: "area",
                stack: '总量',
                barMaxWidth : 30,
                data:[],
                itemStyle: {
                    normal: {
                        color: '#1d83e6',
                    },
                    emphasis: {
                        shadowBlur: 10,
                        shadowOffsetX: 0,
                        shadowColor: 'rgba(0, 0, 0, 0.5)'
                    }
                }
            }
        ]
    };

    $.ajax({
        url: mmssm_url + "inspectionscene/countByDomain",
        type: "POST",
        success: function (data) {
            var countData = [];
            var domainData = [];
            for (var i = 0; i < data.length; i++) {
                countData.push(data[i].count);
                domainData.push(data[i].domain);
            }
            options_zrbm.xAxis[0].data = domainData;
            options_zrbm.series[0].data = countData;
            chart_index_zrbm.setOption(options_zrbm);
        },
        error: function (error) {
            console.log("Count error" + error.status);
        }
    });
}

$(function () {
    showIndexBgfktj();
    showIndexZrbm();


})